from pdf2image import convert_from_path
import pytesseract
from PIL import Image

# 指定 Tesseract 的安装路径
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

# 指定 Poppler 的路径
poppler_path = r'D:\software\poppler-23.11.0\poppler-23.11.0\Library\bin'  # 替换为你的 Poppler 路径

image = Image.open('test1.png')
text = pytesseract.image_to_string(image.convert('L'), lang='chi_sim')  # 中文识别
print(f'识别结果:{text}')
